<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Default="clr-namespace:ICSharpCode.TreeView">

    <SolidColorBrush x:Key="ListBorder"
                     Color="#FF7F9DB9" />

    <Style x:Key="ExpandCollapseToggleStyle"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="Focusable"
                Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Width="9"
                            Height="9"
                            BorderThickness="1"
                            BorderBrush="#FF7898B5"
                            CornerRadius="1"
                            SnapsToDevicePixels="True">
                        <Border.Background>
                            <LinearGradientBrush StartPoint="0,0"
                                                 EndPoint="1,1">
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop Color="White"
                                                  Offset=".2" />
                                    <GradientStop Color="#FFC0B7A6"
                                                  Offset="1" />
                                </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>
                        </Border.Background>
                        <Path Name="ExpandPath"
                              Margin="1,1,1,1"
                              Fill="Black"
                              Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Data" TargetName="ExpandPath" Value="M 0 2 L 0 3 L 5 3 L 5 2 Z" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Default:InsertMarker}">
        <Setter Property="IsHitTestVisible"
                Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Default:InsertMarker}">
                    <Grid>
                        <Border VerticalAlignment="Center"
                                Height="2"
                                Background="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                        <Path Data="m 0 0 l 3 3 l -3 3"
                              Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
                              HorizontalAlignment="Left" />
                        <Path Data="m 0 0 l -3 3 l 3 3"
                              Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
                              HorizontalAlignment="Right" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Default:EditTextBox}">
        <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="KeyboardNavigation.TabNavigation"
                Value="None" />
        <Setter Property="HorizontalContentAlignment"
                Value="Left" />
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="AllowDrop"
                Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Default:EditTextBox}">
                    <Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
                            BorderThickness="1"
                            BorderBrush="{StaticResource ListBorder}"
                            Padding="0 1 2 0">
                        <ScrollViewer Name="PART_ContentHost" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type Default:SharpTreeView}"
           BasedOn="{StaticResource {x:Type ListBox}}">
        <Style.Triggers>
            <Trigger Property="ShowRoot" Value="False">
                <Setter Property="Padding" Value="5 0 0 0" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="{x:Static Default:SharpTreeView.DefaultItemContainerStyleKey}" TargetType="{x:Type Default:SharpTreeViewItem}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ItemsControl.AlternationIndex" Value="1" />
                    <Condition Property="Default:SharpTreeView.ShowAlternation" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="WhiteSmoke" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="{x:Static Default:SharpGridView.ItemContainerStyleKey}" TargetType="{x:Type ListViewItem}">
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListViewItem}">
                    <Border Name="Bd"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="true">
                        <GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        
                    </Border>
                    
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected"
                                 Value="true">
                            <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected"
                                           Value="true" />
                                <Condition Property="Selector.IsSelectionActive"
                                           Value="false" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
                        </MultiTrigger>
                        <Trigger Property="IsEnabled"
                                 Value="false">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Default:SharpTreeViewItem}">
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Default:SharpTreeViewItem}">
                    <Border Background="Transparent">
                        <Border Background="{TemplateBinding Background}">
                            <Default:SharpTreeNodeView x:Name="nodeView"
                                                       HorizontalAlignment="Left" />
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected"
                                 Value="True">
                            <Setter TargetName="nodeView"
                                    Property="TextBackground"
                                    Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                            <Setter TargetName="nodeView"
                                    Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                        </Trigger>
                        <!--<MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected"
                                           Value="True" />
                                <Condition Property="Selector.IsSelectionActive"
                                           Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="nodeView"
                                    Property="TextBackground"
                                    Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                            <Setter TargetName="nodeView"
                                    Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
                        </MultiTrigger>-->
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <!--<Style.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="IsSelected" Value="True"></Setter>
            </DataTrigger>
        </Style.Triggers>-->
    </Style>

    <Style TargetType="{x:Type Default:SharpTreeNodeView}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate x:Name="test" TargetType="{x:Type Default:SharpTreeNodeView}">
                    
                    <Grid>
                        <Default:LinesRenderer x:Name="linesRenderer"
                                               ClipToBounds="True"
                                               Visibility="{Binding ShowLines, RelativeSource={RelativeSource AncestorType={x:Type Default:SharpTreeView}}, Converter={Default:CollapsedWhenFalse}}" />
                        <StackPanel Orientation="Horizontal">
                            <FrameworkElement x:Name="spacer" />
                            <ToggleButton Name="expander"
                                          Style="{StaticResource ExpandCollapseToggleStyle}"
                                          IsChecked="{Binding IsExpanded}"
                                          Visibility="Hidden"
                                          Margin="0 0 6 0"
                                          VerticalAlignment="Center" />
                            <Border Name="checkBoxContainer"
                                    Width="16"
                                    Margin="0 0 3 0"
                                    Visibility="Collapsed">
                                <CheckBox IsChecked="{Binding IsChecked}"
                                          HorizontalAlignment="Center"
                                          VerticalAlignment="Center" />
                            </Border>
                            <StackPanel Orientation="Horizontal"
                                        Background="Transparent"
                                        ToolTip="{Binding ToolTip}">
                                <Image Name="icon" 
                                       Width="16" 
                                       Height="16" 
                                       Margin="0 0 5 1"
                                       VerticalAlignment="Center"
                                       Focusable="False"
                                       Source="{Binding IconUri}" />
                                <Border Name="textContainer" Background="{TemplateBinding TextBackground}">
                                    <ContentControl Content="{Binding Text}"
                                                    Margin="2 0 6 0"
                                                    VerticalAlignment="Center"
                                                    Focusable="False" />
                                </Border>
                                <Border Name="textEditorContainer" />
                            </StackPanel>
                        </StackPanel>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding IsEditing}"
                                     Value="True">
                            <Setter TargetName="textContainer"
                                    Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>
                    	  <DataTrigger Binding="{Binding ShowIcon}"
                                     Value="False">
                    		  <Setter TargetName="icon"
                                    Property="Visibility"
                                   Value="Collapsed" />
 						  </DataTrigger>
                        <DataTrigger Binding="{Binding IsExpanded}"
                                     Value="True">
                            <Setter TargetName="icon"
                                    Property="Source"
                                    Value="{Binding ExpandedIconUri}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ShowExpander}"
                                     Value="True">
                            <Setter TargetName="expander"
                                    Property="Visibility"
                                    Value="Visible" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsCheckable}"
                                     Value="True">
                            <Setter TargetName="checkBoxContainer"
                                    Property="Visibility"
                                    Value="Visible" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsCut}"
                                     Value="True">
                            <Setter TargetName="icon"
                                    Property="Opacity"
                                    Value="0.5" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>

</ResourceDictionary>
